Skip to content

Conversation

@artengin
Copy link
Contributor

Refs: #179

@artengin artengin self-assigned this Oct 29, 2025
@artengin
Copy link
Contributor Author

Cannot create Model:
изображение
изображение

Cannot create Repository:
изображение
изображение

Cannot create Service:
изображение
изображение

Cannot create Controller:
изображение
изображение

Cannot create Factory:
изображение
изображение

Cannot create Nova resource:
php artisan make:entity Post
изображение
php artisan make:entity Forum/Post
изображение

@artengin
Copy link
Contributor Author

Currently, generating Requests, Resources, Migrations, Tests, and Seeders doesn’t verify whether the models exist. If this is a problem, we can go over the details, and I can revise the implementation.

@artengin artengin assigned AZabolotnikov and unassigned artengin Oct 30, 2025
@artengin
Copy link
Contributor Author

I suggest adding checks before generation:

  • For Requests, verify the existence of the Controller
  • For Resources, verify the existence of the Controller
  • For Migrations, verify the existence of the Model
  • For Tests, verify the existence of both the Model and the Controller
  • For Seeders, verify the existence of the Factory

@artengin
Copy link
Contributor Author

artengin commented Nov 3, 2025

Currently, generating Requests, Resources, Migrations, Tests, and Seeders doesn’t verify whether the models exist. If this is a problem, we can go over the details, and I can revise the implementation.

We’ve discussed this question — it’s not relevant for now.

@artengin artengin assigned AZabolotnikov and unassigned artengin Nov 4, 2025
@DenTray
Copy link
Collaborator

DenTray commented Nov 10, 2025

@artengin please resolve conflicts

@DenTray DenTray assigned artengin and unassigned DenTray Nov 10, 2025
@artengin artengin assigned DenTray and unassigned artengin Nov 10, 2025
@DenTray DenTray requested a review from Copilot November 11, 2025 07:11
Copilot finished reviewing on behalf of DenTray November 11, 2025 07:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors exception handling by introducing a new ResourceNotExistsException to replace ClassNotExistsException across multiple generators. The changes standardize error messages and introduce an abstract base exception class for resource-related exceptions.

  • Introduced AbstractResourceException and ResourceNotExistsException to replace ClassNotExistsException
  • Standardized error messages across all generators to follow a consistent format
  • Refactored ResourceAlreadyExistsException to extend the new abstract base class
  • Added a helper method checkResourceNotExists() in EntityGenerator to consolidate duplicate validation logic

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Exceptions/AbstractResourceException.php New abstract base class providing common getEntity() method for resource exceptions
src/Exceptions/ResourceNotExistsException.php New exception class for missing resources with standardized error message format
src/Exceptions/ResourceAlreadyExistsException.php Refactored to extend AbstractResourceException and use inherited getEntity() method
src/Generators/EntityGenerator.php Added checkResourceNotExists() helper method and imports for new exception
src/Generators/ServiceGenerator.php Replaced manual validation logic with checkResourceNotExists() call
src/Generators/RepositoryGenerator.php Replaced manual validation logic with checkResourceNotExists() call
src/Generators/NovaResourceGenerator.php Replaced manual validation logic with checkResourceNotExists() call and added missing import
src/Generators/ModelGenerator.php Replaced manual validation logic with checkResourceNotExists() call
src/Generators/FactoryGenerator.php Replaced manual validation logic with checkResourceNotExists() call
src/Generators/ControllerGenerator.php Replaced manual validation logic with checkResourceNotExists() call
tests/ServiceGeneratorTest.php Updated test to expect ResourceNotExistsException with new error message
tests/RepositoryGeneratorTest.php Updated test to expect ResourceNotExistsException with new error message
tests/NovaResourceGeneratorTest.php Updated test to expect ResourceNotExistsException with new error message
tests/ModelGeneratorTest.php Updated test to expect ResourceNotExistsException with new error message
tests/FactoryGeneratorTest.php Updated test to expect ResourceNotExistsException with new error message
tests/ControllerGeneratorTest.php Updated test to expect ResourceNotExistsException with new error message

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

use RonasIT\Support\DTO\RelationsDTO;
use RonasIT\Support\Events\WarningEvent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use RonasIT\Support\Exceptions\ClassNotExistsException;
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import for ClassNotExistsException is still present but is only used in the getBelongsToModels() method (line 219). Consider whether this method should also be refactored to use ResourceNotExistsException for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
@DenTray DenTray assigned artengin and unassigned DenTray Nov 11, 2025
@artengin artengin assigned DenTray and unassigned artengin Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants